#region Using directives
using System;
using SharpWind.Resources.Meshes;
using Microsoft.DirectX;
using Direct3D = Microsoft.DirectX.Direct3D;
#endregion

namespace SharpWind.Math
{
	public class BoundingBox
	{
		#region Fields

		private Vector3 min = Vector3.Empty;

		private Vector3 max = Vector3.Empty;

		#endregion

		#region Constructor

		public BoundingBox( Vector3 min, Vector3 max )
		{
			this.min = min;
			this.max = max;
		}

		#endregion

		#region Methods

		public static BoundingBox ComputeFromMesh( Mesh mesh )
		{
			Vector3 min;
			Vector3 max;
			Direct3D.Geometry.ComputeBoundingBox( mesh.DxMesh.VertexBuffer.Lock( 0, 0, Direct3D.LockFlags.None ),
												  0, 0, out min, out max );

			return new BoundingBox( min, max );
		}

		#endregion

		#region Properties

		public Vector3 Min 
		{
			get
			{
				return this.min;
			}
			set
			{
				this.min = value;
			}
		}

		public Vector3 Max
		{
			get
			{
				return this.max;
			}
			set
			{
				this.max = value;
			}
		}

		#endregion
	}
}
